package com.mvp.lt.airlineview.base;

import android.app.Application;
import android.content.Context;


import androidx.multidex.MultiDex;

import com.mvp.lt.airlineview.data.constant.LC;
import com.mvp.lt.airlineview.data.entity.User;
import com.mvp.lt.airlineview.data.source.dbutils.UserDataDbUtils;
import com.mvp.lt.airlineview.data.source.helper.SPManager;


/**
 * $activityName
 *
 * @author LiuTao
 * @date 2019/2/20/020
 */

public abstract class BaseApp  extends Application {
    private static BaseApp INSTANCE;
    public User mUser;

//    public  BaseApp(int tinkerFlags, String delegateClassName, String loaderClassName, boolean tinkerLoadVerifyFlag) {
//        super(tinkerFlags, delegateClassName, loaderClassName, tinkerLoadVerifyFlag);
//    }


    public static BaseApp getInstance() {
        return INSTANCE;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        MultiDex.install(this);
        INSTANCE = this;
        init();
        Long id = SPManager.getLong(SPManager.SP_MAIN_FLAG, LC.USER_ACCOUNT_ID);
        mUser = UserDataDbUtils.getInstance().quearyDataByIDFromDb(id);
    }

    protected abstract void init();

    public static Context getContext() {
        return INSTANCE;
    }

    public User getUser() {
        if (mUser == null) {
            mUser = new User();
        }
        return mUser;
    }

    public void setUser(User user) {
        mUser = user;
    }
}
